package com.jzwl.site.wap.index.controller;

import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.google.common.base.Objects;
import com.google.common.collect.Maps;
import com.jzwl.common.constant.AjaxStatusConstant;
import com.jzwl.common.constant.Constants;
import com.jzwl.common.page.PageObject;
import com.jzwl.common.utils.HttpClientUtil;
import com.jzwl.enums.DataTypeEnum;
import com.jzwl.enums.MenuDDJSTypeEnum;
import com.jzwl.enums.MenuQYSHZRWHTypeEnum;
import com.jzwl.enums.MenuTypeEnum;
import com.jzwl.enums.MenuZHCTDLWHTypeEnum;
import com.jzwl.site.manager.company.service.SiteCompanyService;
import com.jzwl.site.wap.index.service.WebService;
import com.jzwl.system.base.controller.BaseController;

@Controller
@RequestMapping("/web")
public class WebController extends BaseController {

	@Autowired
	private WebService webService;

	@Autowired
	private Constants constants;

	@Autowired
	private SiteCompanyService siteCompanyService;

	private static Logger log = LoggerFactory.getLogger(WebController.class);

	/**
	 * 项目跳转进入
	 * @Date 2018年9月11日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/index")
	public ModelAndView articleIndex(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mov = new ModelAndView();
		createParameterMap(request);
		//webService.queryNode();
		//加载图片服务器地址
		mov.addObject("flag", "-1");
		mov.addObject("menuId", "1535712460347002");
		mov.addObject("staticpath", constants.getSftz_online_path());
		mov.setViewName("/wap/party/home");
		return mov;
	}

	/**
	 * 外部项目跳转进入
	 * @Date 2018年9月11日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/setLink")
	public ModelAndView setLink(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mov = new ModelAndView();
		createParameterMap(request);
		String id = (String) paramsMap.get("id");
		String type = (String) paramsMap.get("type");
		String[] strs = type.split("-");
		int flag = 1;
		//Map<String, Object> result = webService.queryNodeInfoById(id);
		mov.addObject("flag", flag);
		mov.addObject("menuId", id);
		mov.setViewName("/wap/party/index");
		return mov;
	}

	/**
	 * 测试内容
	 * (这里用一句话描述这个方法的作用)
	 * @Date 2018年9月11日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/setdemoLink")
	public ModelAndView setdemoLink(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mov = new ModelAndView();
		createParameterMap(request);
		String id = (String) paramsMap.get("id");
		String articleId = (String) paramsMap.get("articleId");
		int flag = 1;
		//Map<String, Object> result = webService.queryNodeInfoById(id);
		mov.addObject("flag", flag);
		mov.addObject("menuId", id);
		mov.addObject("articleId", articleId);
		mov.setViewName("/wap/party/art_index");
		return mov;
	}

	@RequestMapping(value = "/getMenu")
	public @ResponseBody Map<String, Object> getMenu(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		createParameterMap(request);
		//获取一级分类
		List<Map<String, Object>> mlist = webService.queryFirstMenu();
		resultMap.put("mlist", mlist);
		resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		return resultMap;
	}

	/**
	 * 1-首页获取一级导航
	 * @Date 2018年9月11日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/getFirstMenuHome")
	public @ResponseBody Map<String, Object> getFirstMenuHome(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		createParameterMap(request);
		//获取一级分类
		List<Map<String, Object>> mlist = webService.getFirstMenu();
		resultMap.put("mlist", mlist);
		resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		return resultMap;
	}

	/**
	 * 1-获取一级分类
	 * (这里用一句话描述这个方法的作用)
	 * @Date 2018年9月6日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/getFirstMenu")
	public @ResponseBody Map<String, Object> getFirstMenu(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		createParameterMap(request);
		//获取一级分类
		List<Map<String, Object>> mlist = webService.queryFirstMenu();
		resultMap.put("mlist", mlist);
		resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		return resultMap;
	}

	/**
	 * 1-根据一级分类的id获取所有的子分类
	 * (这里用一句话描述这个方法的作用)
	 * @Date 2018年9月6日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/querySecondMenu")
	public @ResponseBody Map<String, Object> querySecondMenu(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		createParameterMap(request);
		String menuId = paramsMap.get("menuId").toString();
		//获取一级分类
		List<Map<String, Object>> secondMenus = webService.querySecondMenu(menuId);
		resultMap.put("secondMenus", secondMenus);
		if (secondMenus.size() >= 0) {//获取默认的二级分类的id
			resultMap.put("secondId", secondMenus.get(0).get("id"));
		} else {
			resultMap.put("secondId", "-1");
		}
		resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		return resultMap;
	}

	/**
	 * 根据类型，获取数据
	 * @param type
	 * @param request
	 * @param response
	 * @return TODO(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/{type}")
	public @ResponseBody Map<String, Object> acquisitionData(@PathVariable String type, HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//dwjs：党务建设
		if (Objects.equal(type, DataTypeEnum.dwjs.getValue())) {
			//
		}
		return resultMap;
	}

	/**
	 * 1-判断点击导航系统要跳转的类型
	 * @Date 2018年9月6日
	 * @author gyp
	 * @param type 按钮类型
	 * @param menuId 按钮的id
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/{type}/{menuId}")
	public ModelAndView articleDetail(@PathVariable String type, @PathVariable String menuId,
			HttpServletRequest request, HttpServletResponse response) {
		createParameterMap(request);
		ModelAndView mov = new ModelAndView();
		//判断跳转的类型
		try {
			if (Objects.equal(type, MenuTypeEnum.zcfg.getValue())) {//政策法规的相关页面
				//mov.setViewName("redirect:/web/zcfg.html");
				//mov.setViewName("/wap/party/home_zcfg");
				mov.setViewName("/wap/party/zcfg");
				mov.addObject("menuId", menuId);
			} else if (Objects.equal(type, MenuTypeEnum.home.getValue())) {
				mov.setViewName("/wap/party/home");
				mov.addObject("menuId", menuId);
			} else if (MenuTypeEnum.djzd_ktyj_ktyj.getName().equals(type)
					|| MenuTypeEnum.djzd_ktyj_ztlt.getName().equals(type)
					|| MenuTypeEnum.djzd_ktyj_hdsq.getName().equals(type)
					|| MenuTypeEnum.djzd_ktyj_ktzx.getName().equals(type)) {
				//课题研究
				mov.setViewName("/wap/party/i-r-e-ly");
				mov.addObject("menuId", menuId);
			} else if (MenuTypeEnum.djzd_dfzg_gjjs.getName().equals(type)
					|| MenuTypeEnum.djzd_dfzg_lfzg.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_zljd_zdzl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_zljd_ggzl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_zljd_mszl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_zljd_jjzl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_zljd_lzzl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_zljd_qjzl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_zljd_wjzl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_dnyg.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_dsgs.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_hywx.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_zjsj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_xixl.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_gccf.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_szjj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_dsds_dwzn.getName().equals(type)
					//*********************************
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrgs_xztz.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrgs_xggn.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrgs_cybj.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrgs_zrlx.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrgs_fajdtz.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrgs_kcxfz.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrgs_iso.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_gjqysj_zyqqxcy.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_gjqysj_omxdjh.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_gjqysj_omcy.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_gjqysj_gjbzzn.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrnr_qyshzr.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrnr_qyjjzr.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrnr_qystzr.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrnr_qywhzr.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrnr_qysdzr.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrtxgj_gjbz.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrtxgj_gjfz.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrtxgj_cyzd.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrtxgj_qygy.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrtxgj_qywh.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrtxgj_dsxy.getName().equals(type)
					|| MenuQYSHZRWHTypeEnum.qyshzrwh_qyzrtxgj_zrgl.getName().equals(type)

					//-----中华传统德理文化-----------
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_xs_xszd.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_xs_jkzd.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_qj_zdcc.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_qj_xsyy.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_qj_jfjx.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_qj_wlbd.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_qj_dayr.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_zg_ddgjdzgfz.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_zg_xjpzgsxjd.getName().equals(type)
					|| MenuZHCTDLWHTypeEnum.zhctdlwh_zg_sxzh.getName().equals(type)) {

				//党建之道-德法治国-国家精神、党建之道-德法治国-礼法治国
				mov.setViewName("/wap/party/i-r-e-lf");
				mov.addObject("menuId", menuId);
			} else if (MenuTypeEnum.djzd_dfzg_djjy.getName().equals(type)
					|| MenuTypeEnum.djzd_zjgd.getName().equals(type)) {
				//党建之道-德法治国-大家谏言、党建之道-专家观点
				mov.setViewName("/wap/party/i-r-e-lp");
				mov.addObject("menuId", menuId);

			} else if (MenuDDJSTypeEnum.ddjs_djzh_fgqydj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_gyqydj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_lxdj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_ncdj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_qydj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_sqdj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_jgdj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_jddj.getName().equals(type)
					|| MenuDDJSTypeEnum.ddjs_djzh_gxdj.getName().equals(type)) {
				mov.setViewName("/wap/party/i-e-r-c-j-lf");
				mov.addObject("menuId", menuId);
				mov.addObject("typeId", MenuDDJSTypeEnum.ddjs_djzh_fgqydj.getTypeId());
			} else if (MenuZHCTDLWHTypeEnum.zhctdlwh_ptx.getName().equals(type)) {

				mov.setViewName("/wap/party/i_lp-ptx");
				mov.addObject("menuId", menuId);

			} else if (MenuTypeEnum.djzd_sfjd.getName().equals(type)) {
				mov.setViewName("/wap/party/i-e-r-lp_sfjd");
				mov.addObject("menuId", menuId);
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return mov;
	}

	/**
	 * 1-获取推荐内容
	 * @Date 2018年9月7日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/getRecomdContent")
	public @ResponseBody Map<String, Object> getRecomdContent(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = Maps.newConcurrentMap();
		try {
			createParameterMap(request);
			String menuId = paramsMap.get("menuId").toString();
			///获取当前栏目文章列表
			Map<String, Object> map = webService.getRecomdContent(menuId);
			resultMap.put("menuId", menuId);
			resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
			resultMap.put("map", map);
		} catch (Exception e) {
			ModelAndView mov = new ModelAndView();
			e.printStackTrace();
			mov.addObject("msg", "Article列表查询失败");
			mov.setViewName("/error");
		}
		return resultMap;
	}

	/**
	 * 1-根据导航的id获取文章的内容
	 * @Date 2018年9月6日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/getRecomdArticleList")
	public @ResponseBody Map<String, Object> getRecomdArticleList(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> resultMap = Maps.newConcurrentMap();
		try {
			createParameterMap(request);
			String menuId = paramsMap.get("menuId").toString();
			List<Map<String, Object>> listData = webService.getRecomdArticleList(menuId);
			resultMap.put("recomdArticleList", listData);
			resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		} catch (Exception e) {
			ModelAndView mov = new ModelAndView();
			e.printStackTrace();
			mov.addObject("msg", "Article列表查询失败");
			mov.setViewName("/error");
		}
		return resultMap;
	}

	/**
	 * 1-根据导航的id获取文章的列表
	 * @Date 2018年9月6日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/queryArticleList")
	public @ResponseBody Map<String, Object> queryArticleList(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = Maps.newConcurrentMap();
		try {
			createParameterMap(request);
			String menuId = paramsMap.get("menuId").toString();

			///获取当前栏目文章列表
			PageObject po = webService.queryArticleList(paramsMap);
			List<Map<String, Object>> listData = po.getDatasource();
			resultMap.put("totalProperty", po.getTotalCount());
			resultMap.put("page", po);
			resultMap.put("menuId", menuId);
			resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		} catch (Exception e) {
			ModelAndView mov = new ModelAndView();
			e.printStackTrace();
			mov.addObject("msg", "Article列表查询失败");
			mov.setViewName("/error");
		}
		return resultMap;
	}

	/**
	 * 1-获取文章的详情
	 * @Date 2018年9月7日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/artcle/goArticleDetail")
	public ModelAndView goArticleDetail(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mov = new ModelAndView();
		createParameterMap(request);

		String articleId = paramsMap.get("articleId").toString();
		try {
			String imgPreUrl = constants.getSftz_online_path();
			mov.addObject("articleId", articleId);
			mov.addObject("imgPreUrl", imgPreUrl);
			mov.setViewName("/wap/party/articlesDetail");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mov;
	}

	/**
	 * 1-获取文章的接口部分
	 * @Date 2018年9月7日
	 * @author gyp
	 * @param articleId
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "/artcle/{articleId}")
	public @ResponseBody Map<String, Object> getArticleDetail(@PathVariable String articleId,
			HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = Maps.newConcurrentMap();
		try {
			Map<String, Object> map = webService.getArticleDetail(articleId);
			resultMap.put("map", map);
			resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
			return resultMap;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 点击导航操作入口
	 * @Date 2018年9月3日
	 * @author gyp
	 * @param nodeid
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/{nodeid}")
	public ModelAndView nodeList(@PathVariable String nodeid, HttpServletRequest request, HttpServletResponse response) {
		createParameterMap(request);
		//获取导航接口。
		ModelAndView mov = loadMenuInfo(nodeid);

		///获取当前栏目文章列表
		PageObject po = new PageObject();
		try {
			Map<String, Object> currmap = (Map<String, Object>) mov.getModel().get("currentNode");
			paramsMap.put("isDelete", 0);
			if (currmap != null) {
				paramsMap.put("nodeId", currmap.get("id"));
			}

			//			paramsMap.put("limit", 2);///测试使用

			po = webService.queryArticleList(paramsMap);
			List<Map<String, Object>> listData = po.getDatasource();
			if (listData.size() == 1) {//当栏目下只有一个的时候，直接进入详情页面
				mov.setViewName("redirect:/web/" + listData.get(0).get("nodeId") + "/"
						+ listData.get(0).get("articleId") + ".html");
				return mov;
			}
			//			po.setPageSize(2);
			mov.addObject("totalProperty", po.getTotalCount());
			mov.addObject("page", po);
			mov.addObject("tarId", nodeid);
			mov.setViewName("/wap/site/list");
		} catch (Exception e) {

			e.printStackTrace();
			mov.addObject("msg", "Article列表查询失败");
			mov.setViewName("/error");
		}
		return mov;
	}

	/**
	 * 跳转到静态页面
	 * (这里用一句话描述这个方法的作用)
	 * @Date 2018年1月23日
	 * @author gyp
	 * @param request
	 * @param response
	 * @return(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/jump")
	public ModelAndView jump(HttpServletRequest request, HttpServletResponse response) {
		createParameterMap(request);
		String data = (String) paramsMap.get("data");
		ModelAndView mov = new ModelAndView();
		//加载顶部menu动态部分
		List<Map<String, Object>> mlist = webService.queryFirstMenu();
		mov.addObject("mlist", mlist);

		mov.setViewName("/wap/site/html_" + data);
		return mov;
	}

	protected ModelAndView loadMenuInfo(String nodeid) {
		ModelAndView mov = new ModelAndView();

		//加载顶部menu动态部分
		List<Map<String, Object>> mlist = webService.queryFirstMenu();
		mov.addObject("mlist", mlist);
		//当前栏目Id
		Map currentNode = null;
		Map currentMenu;
		//获取当前栏目信息
		Map cnmap = webService.queryNodeInfo(nodeid);

		List<Map<String, Object>> chnodelist = new ArrayList<Map<String, Object>>();
		if (Long.parseLong(cnmap.get("parentId").toString()) == 0) {
			chnodelist = webService.queryNodeBypid(cnmap.get("id"));
			if (chnodelist.size() > 0) {
				currentNode = chnodelist.get(0);
			}
			currentMenu = cnmap;
		} else {
			chnodelist = webService.queryNodeBypid(cnmap.get("parentId"));
			currentNode = cnmap;
			currentMenu = webService.queryNodeInfo(cnmap.get("parentId"));
		}

		mov.addObject("currentMenu", currentMenu);
		mov.addObject("currentNode", currentNode);
		mov.addObject("chlist", chnodelist);
		mov.addObject("cnodeid", nodeid);

		return mov;
	}

	@RequestMapping(value = "/read")
	public @ResponseBody Map<String, Object> read(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		createParameterMap(request);
		try {
			boolean flag = webService.addClickInfo(paramsMap);
			if (!flag) {
				resultMap.put("msg", "修改失败!");
			} else {
				resultMap.put("error", "获取栏目数异常");
			}
		} catch (Exception e) {
			e.printStackTrace();
			resultMap.put("error", "获取栏目数异常");
		}
		return resultMap;
	}

	@RequestMapping(value = "/loadpic")
	public @ResponseBody Map<String, Object> loadpic(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		createParameterMap(request);
		///加载轮播图信息
		List<Map<String, Object>> alist = webService.queryTopArticle();
		resultMap.put("alist", alist);
		return resultMap;
	}

	@RequestMapping(value = "/company")
	public @ResponseBody Map<String, Object> companyDeail(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("ajax_status", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
		createParameterMap(request);
		PageObject obj = siteCompanyService.querySiteCompanyList(resultMap);
		resultMap.put("obj", obj);
		return resultMap;
	}

	public String checkMoth(String str) {
		if (str.equals("01")) {
			return "JAN";
		}
		if (str.equals("02")) {
			return "FEB";
		}
		if (str.equals("03")) {
			return "MAR";
		}
		if (str.equals("04")) {
			return "APR";
		}
		if (str.equals("05")) {
			return "MAY";
		}
		if (str.equals("06")) {
			return "JUN";
		}
		if (str.equals("07")) {
			return "JUL";
		}
		if (str.equals("08")) {
			return "AUG";
		}
		if (str.equals("09")) {
			return "SEP";
		}
		if (str.equals("10")) {
			return "OCT";
		}
		if (str.equals("11")) {
			return "NOV";
		}
		if (str.equals("12")) {
			return "DEC";
		}
		return "";
	}

	/**
	 * 
	 * 项目名称：sftj-offical-site
	 * 描述：跳转添加用户信息
	 * 创建人： ln
	 * 创建时间： 2016年11月30日
	 * 标记：PC
	 * @param request
	 * @param response
	 * @return
	 * @version
	 */
	@RequestMapping(value = "/toAddUserIndex")
	public ModelAndView toAddUserIndex(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mov = new ModelAndView();
		createParameterMap(request);
		//加载顶部menu动态部分
		List<Map<String, Object>> mlist = webService.queryFirstMenu();
		mov.addObject("mlist", mlist);
		mov.setViewName("/wap/skillsharing");
		return mov;
	}

	/**
	 * 
	 * 项目名称：sftj-offical-site
	 * 描述：H5跳转添加用户信息
	 * 创建人： ln
	 * 创建时间： 2016年11月30日
	 * 标记：wap
	 * @param request
	 * @param response
	 * @return
	 * @version
	 */
	@RequestMapping(value = "/toAddUserIndexH5")
	public ModelAndView toAddUserIndexH5(HttpServletRequest request, HttpServletResponse response) {
		createParameterMap(request);
		ModelAndView mov = new ModelAndView();
		mov.setViewName("/wap/jinengH5");
		return mov;
	}

	/**
	 * 
	 * 项目名称：sftj-offical-site
	 * 描述：添加用户信息
	 * 创建人： ln
	 * 创建时间： 2016年11月30日
	 * 标记：
	 * @param request
	 * @param response
	 * @return
	 * @version
	 */
	@RequestMapping(value = "/addUserIndex")
	public @ResponseBody Map<String, Object> addUserIndex(HttpServletRequest request, HttpServletResponse response) {
		createParameterMap(request);
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			boolean flag = webService.addUserIndex(paramsMap);
			map.put("flag", flag);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
	}

	/**
	 * 
	 * 项目名称：sftj-offical-site
	 * 描述：验证用户
	 * 创建人： ln
	 * 创建时间： 2016年12月2日
	 * 标记：
	 * @param request
	 * @param response
	 * @return
	 * @version
	 */
	@RequestMapping(value = "/checkUser")
	public @ResponseBody Map<String, Object> checkUser(HttpServletRequest request, HttpServletResponse response) {
		createParameterMap(request);
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			boolean flag = webService.checkUser(paramsMap);
			map.put("checkFlag", flag);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
	}

	/**
	 * ajax方式获取js签名
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getJSConfig")
	public String getJSConfig(HttpServletRequest request, String clientUrl, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String resStr = null;
		try {
			String cUrl = clientUrl;
			cUrl = URLEncoder.encode(cUrl, "UTF-8");
			log.info("++++++++++++++++cUrl:" + cUrl);
			//String url = constants.getXiaoka_weixin_xydk_toGetJsConfig(); //暂时注释签名
			String url = null;
			log.info("=================clientUrl=================" + clientUrl);
			resultMap = HttpClientUtil.requestByGetMethod(url + "?clientUrl=" + cUrl);
			log.info("<<<<<<<<<<<clientUrl=================" + clientUrl);
			resStr = (String) resultMap.get("token");
		} catch (Exception e) {
			e.printStackTrace();
			log.info("<<<<<<<<<<<ajax方式获取js签名失败<<<<<<<<<<<<");
			resultMap.put("msg", "0");
			return resStr;
		}
		return resStr;
	}

	/**
	 * 微信分享入口
	 * @param session
	 * @param shareUrl 被分享页面的url
	 * @return
	 * @throws IllegalArgumentException
	 */
	@RequestMapping(value = "/wxShare")
	public String wxShare(final HttpServletRequest req, String shareUrl) {
		return "redirect:" + shareUrl;
	}

	/**
	 * 获取js签名
	 */
	/*@ResponseBody
	@RequestMapping(value = "/getJSConfig")
	public Object getJSConfig(String clientUrl) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		String resStr = null;
		try{
			String url = constants.getXiaoka_weixin_xydk_toGetJsConfig();
			String ecodUrl = URLEncoder.encode(clientUrl,"UTF-8");
			resultMap = HttpClientUtil.requestByGetMethod(url+"?clientUrl="+ecodUrl);
			resStr = (String) resultMap.get("token");
		}catch(Exception e){
			e.printStackTrace();
			//log.info("<<<<<<<<<<<ajax方式获取js签名失败<<<<<<<<<<<<");
			resultMap.put("msg","0");
			return resStr;
		}
		return resStr;
	}*/

	/**
	 * 
	 * 项目名称：sftj-offical-site
	 * 描述：新闻列表，用于手机端入口。H5
	 * 创建人： ln
	 * 创建时间： 2017年1月6日
	 * 标记：
	 * @param request
	 * @param response
	 * @return
	 * @version
	 */
	@RequestMapping(value = "/toNewsList")
	public ModelAndView toNewsList(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mov = new ModelAndView();
		mov.setViewName("/wap/news/newlist");
		return mov;
	}

	/**
	 * 
	 * 项目名称：sftj-offical-site
	 * 描述：新闻列表，用于手机端入口。H5
	 * 创建人： ln
	 * 创建时间： 2017年1月6日
	 * 标记：
	 * @param request
	 * @param response
	 * @return
	 * @version
	 */
	@RequestMapping(value = "/newsList")
	public @ResponseBody Map<String, Object> newsList(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> map = new HashMap<String, Object>();
		createParameterMap(request);
		try {
			paramsMap.put("limit", 10);
			PageObject po = webService.queryNewsList(paramsMap);
			/*List<Map<String,Object>> listTop = webService.queryNewListTop(paramsMap);*/
			List<Map<String, Object>> datasource = po.getDatasource();

			for (int i = 0; i < datasource.size(); i++) {
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				String dateString = formatter.format(datasource.get(i).get("pubTime"));
				datasource.get(i).put("pubTime", dateString);
			}
			map.put("list", po.getDatasource());
			map.put("currentPage", po.getCurrentPage());
			/*map.put("listTop", listTop);*/
			String imgPreUrl = constants.getSftz_online_path();
			map.put("imgPreUrl", imgPreUrl);
			return map;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 
	 * 项目名称：sftj-offical-site
	 * 描述：更新阅读人数H5
	 * 创建人： ln
	 * 创建时间： 2017年1月6日
	 * 标记：WAP
	 * @param request
	 * @param response
	 * @return
	 * @version
	 */
	@RequestMapping(value = "/updateReadNum")
	public @ResponseBody Map<String, Object> updateReadNum(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> map = new HashMap<String, Object>();
		createParameterMap(request);
		try {
			webService.updateReadNum(paramsMap);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
	}

}
